From: Aaron Schulz Date: Thu, 14 Jul 2011 17:39:04 +0000 (+0000) Subject: Made WikiPage::factory a bit more dummy proof X-Git-Tag: 1.31.0-rc.0~28842 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=0b1eb48108274be6358a282b4d7f28948b77ddb6;p=lhc%2Fweb%2Fwiklou.git Made WikiPage::factory a bit more dummy proof --- diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 1d7f2fae70..8804f834f9 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -54,9 +54,15 @@ class WikiPage extends Page { * @return WikiPage object of the appropriate type */ public static function factory( Title $title ) { - switch( $title->getNamespace() ) { - case NS_MEDIA: - throw new MWException( "NS_MEDIA is a virtual namespace" ); + $ns = $title->getNamespace(); + + if ( $ns == NS_MEDIA ) { + throw new MWException( "NS_MEDIA is a virtual namespace; use NS_FILE." ); + } elseif ( $ns < 0 ) { + throw new MWException( "Invalid or virtual namespace $ns given." ); + } + + switch ( $ns ) { case NS_FILE: $page = new WikiFilePage( $title ); break;